<template>
  <div class="order">
    <el-card>
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="商户授权" name="first">
          <div style="width:1920px;height:785px">
            <iframe style="width:100%;height:100%" src="https://e.dianping.com/dz-open/merchant/auth?app_key=f72648a9d79af3a4&state=teststate" frameborder="0" />
          </div>
        </el-tab-pane>
      </el-tabs>
    </el-card>
  </div>
</template>

<script>
import { getGoodsTypePage, delGoodsType } from '@/api/user'
export default {
  data() {
    return {
      activeName: 'first',
      params: {},
      loading: false,
      listData: [],
      mdl: {},
      parentId: 0,
      dialog: false, // 新增、编辑弹框
      condition: {
        current: 1,
        size: 10
      }
    }
  },
  computed: {},
  created() {
    // this.getList()
  },
  mounted() {
    window.addEventListener('message', this.handleMessage)
  },
  ready() {
    // window.addEventListener('message', this.handleWinFocus, false)
  },
  beforeDestroy() {
    window.removeEventListener('message', this.handleMessage)
  },
  methods: {
    handleMessage(e) {
      // console.log(e)
      // alert(e.data.auth_code)
    },
    // 删除
    delBtn(row) {
      const that = this
      that.$confirm('确认删除？')
        .then(_ => {
          delGoodsType({
            id: row.id
          }).then(res => {
            if (res.statusCode === '00000') {
              that.getList()
            }
          })
        })
        .catch(_ => {

        })
    },
    // 获取列表
    getList() {
      getGoodsTypePage(this.condition).then(res => {
        if (res.statusCode === '00000') {
          this.listData = res.data.records
        }
      })
    },

    // 搜索按钮
    onSearch() {
      console.log(this.params)
      this.getList()
    },

    // 新增-弹窗
    addPop() {
      this.dialog = true
      this.mdl = {}
    },

    // 修改-弹窗
    editPop(item) {
      console.log(item)
      this.mdl = Object.assign({}, item)
      this.dialog = true
    },

    // 关闭dialog方法
    handleCloseDialog() {
      this.dialog = false
    }
  }
}
</script>

<style lang="scss" scoped>
.order {
  margin: 20px;
}
</style>
